/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
    var instance = {
        initComponent: function (params,widget) {
        	var subnav = new Subnav({
        		parentNode:".J-subnav",
        		model:{
        			title:"车辆档案",
        			items:[{
						id:"search",
						type: "search",
						placeholder: "车辆型号/车牌号码",
						handler: function(str){
							aw.ajax({
								url: "api/carfile/search",
								data: {
									s: str,
									searchProperties: "carType,carNumber",
									fetchProperties: "pkCar,carType,carNumber,perNmber,bagNumber,carStatus"
								},
								success: function(data){
									widget.get("grid").setData(data);
								}
							});
						}
            		},{
        				id:"status",
        				type:"buttongroup",
        				tip:"状态",
        				items:[{
        					key:"Free",
        					value:"空闲"
        				},{
        					key:"Running",
        					value:"出车"
        				},{
        					key:"false",
        					value:"禁用"
        				}],
	        			all: {
	    					show: true,
	    					position: "bottom"
	    				},
	    				handler:function(key,element){
							widget.get("grid").refresh();
						}
        			},{
        				id: "add",
        				type: "button",
        				text: "新增",
        				handler: function(){
        					
        					form = widget.get("form");
        					form.reset();
        					widget.hide([".J-grid"]).show([".J-form"]);
        					widget.get("subnav").hide(["status","add","search"]);
        				}
        			}]
        		}
        	});
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
